package com.itheima.controller.user;

import com.itheima.common.result.Result;
import com.itheima.dto.IndexPageDTO;
import com.itheima.dto.UserLoginDTO;
import com.itheima.pojo.YddUser;
import com.itheima.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("userIndexController")
@RequestMapping("index")
public class IndexController {
    @Autowired
    IndexService indexService;

    @GetMapping("index")
    public Result index(){
        return indexService.index();
    }

    @GetMapping("new")
    public Result indexNew(Integer page,Integer limit){
        return indexService.indexNew(page,limit);
    }

    @GetMapping("hot")
    public Result hot(){
        return indexService.hot();
    }

    @GetMapping("recommend")
    public Result recommend(){
        return indexService.recommend();
    }

    @GetMapping("list")
    public Result indexList(IndexPageDTO dto){
      return indexService.indexList(dto);
    }

    @PostMapping("reg")
    public Result reg(@RequestBody YddUser user){
        return indexService.reg(user);
    }

    @GetMapping("show")
    public Result show(Integer id){
        return indexService.show(id);
    }

}
